#pragma once

class CStdioFile;

class CTextStream
{
public:
	CTextStream(CStdioFile *device);

	CTextStream(FILE *internalFile);

	virtual ~CTextStream();

	CTextStream &operator<<(TCHAR ch);
	CTextStream &operator<<(signed short i);
	CTextStream &operator<<(unsigned short i);
	CTextStream &operator<<(signed int i);
	CTextStream &operator<<(unsigned int i);
	CTextStream &operator<<(signed long i);
	CTextStream &operator<<(unsigned long i);
	CTextStream &operator<<(float f);
	CTextStream &operator<<(double f);
	CTextStream &operator<<(const CString &s);
	CTextStream &operator<<(const TCHAR *c);

private:
	void flushWriteBuffer();

	void write(const TCHAR *data, int len);

	void write(TCHAR ch);

	void write(const CString& str);

private:
	//CString		_strReadBuffer;
	CString		_writeBuffer;
	CStdioFile	*_device;
	FILE		*_internalFile;
};